package Controllers

import (
	"github.com/gin-gonic/gin"
	"yz-go/Common"
	"yz-go/Logic"
)

func GetCityList(c *gin.Context) {
	page, size := 1, 10
	// 解析页码和每页条数参数
	pageStr := c.Query("page")
	if pageStr != "" {
		res := Common.Strconv(pageStr)
		if res.Status == Common.ERROR {
			Common.ErrorResponse(c, Common.ERROR, res.Msg)
			return
		}
		page = res.Inter
	}

	sizeStr := c.Query("size")
	if sizeStr != "" {
		res := Common.Strconv(sizeStr)
		if res.Status == Common.ERROR {
			Common.ErrorResponse(c, Common.ERROR, res.Msg)
			return
		}
		size = res.Inter
	}

	res := Logic.GetCityList(page, size, c)

	Common.SuccessResponse(c, Common.SUCCESS, res)
}
